package com.wg.wuge.study.designmodel.tulingxueyuan;

/**
 * 工厂方法设计模式
 */
public class Factory {
    public static void main(String[] args) {
        createProductA1 createP = new createProductA1();
        createP.create().method1();

    }

}
interface Product{
    public void method1();
}
class ProductA implements Product{
    public void method1() {
        System.out.println("product method1");
    }
}
class ProductA1 implements Product{
    public void method1() {
        System.out.println("productA1 method1");
    }
}
class createProductA extends createProduct{
    public Product create() {
        return new ProductA();
    }
}
class createProductA1 extends createProduct{
    public Product create() {
        return new ProductA1();
    }
}
abstract class createProduct {
    public Product create() {
        return null;
    }

}